# $(shell ~)
PWD=$(shell pwd)
$(info ${PWD})
 
include ${PWD}/config.mk
 
#target
TARGET := ssiot-applet-liteai
 
#toolchain
CXX	:= g++   
CC  := gcc
 
#flags
CFLAGS	:= -g -O2    
CXXFLAGS := $(CFLAGS) -std=c++11 -lstdc++ -Wall -Wsign-compare 
#CXXFLAGS += $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
 
#lib 
LINK_OPTIONS	= -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
 
LDFLAGS    		:= 
DEFINES    		:=
LIBPATHS 		:= $(addprefix -L, $(LIBS))
LIBPATHS 		+= ${LDFLAGS}
 
LD_LIBRARY_PATH =
 

#include
HDRPATHS := $(addprefix -I, $(HDRS))
HDRS = ./
HDRPATHS += $(addprefix -I$(PWD)/, $(HDRS))
$(info "******${HDRPATHS}")
 
#Source files
SOURCE := 	main.cpp\
			ssiot/msgbus.cpp\
			ssiot/settings.cpp\
			ssiot/ssiot.cpp\
			stream/record.cpp\
			stream/rtsp.cpp\
			stream/event.cpp\
			stream/stream.cpp\
			liteai/yolo.cpp

# %.cpp -> %.o
OBJS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
$(info "****$(OBJS)")
 
.PHONY:all
all:$(TARGET)
 
# link
$(TARGET):$(PROTO_OBJS) $(OBJS)
	$(CXX) ${LIBPATHS} ${LINK_OPTIONS} -o $@ 
 
%.o:%.cpp
	$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@
  
%.o:%.cc
	@echo "Compiling $@"
	@$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@
 
.PHONY:clean
clean:
	rm -rf ${TARGET} $(OBJS)